package com.nwpu.coursesupport.controller;

import javax.servlet.http.HttpServletRequest;

import com.nwpu.coursesupport.entity.ForumModule;
import com.nwpu.coursesupport.mapper.ForumModuleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
public class ForumController extends AbstractController{
	
	@Autowired
	private ForumModuleMapper forumModuleMapper;

	@RequestMapping("/forum")
	public String list(@RequestParam("courseId")Integer courseId, Model model){
		List<ForumModule> forumModules = forumModuleMapper.selectByExample(null);//

		model.addAttribute("forumModules",forumModules);
		return "/teapage/forum-index";
	}
	@RequestMapping("/createModule")
	public String createModule(ForumModule forumModule){
		forumModuleMapper.insert(forumModule);
		return "redirect:/forum";
	}

}
